package com.xyy.saas.payment.controller;

import com.xyy.me.sso.client.pac4j.Pac4jConfigurationProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * 管理平台登出接口
 */
@RestController
@RequestMapping("/logout")
@DependsOn({"pac4jConfiguration"})
public class LogoutController {

    @Autowired
    private Pac4jConfigurationProperties pac4jProperties;

    /** 登出 */
    @RequestMapping("/default")
    public void logoutDefault(HttpSession session, HttpServletResponse response) throws IOException {
        session.invalidate();
        //直接退出，走默认退出方式
        response.sendRedirect(pac4jProperties.getCasServerUrl()+"/logout");
    }

    @RequestMapping("/logout/success")
    public String logout(){
        return"redirect:/";
    }

}
